package hk.cic.demointegrationapp;

import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import com.cily.utils.log.BaseWv;

public class CheckInOrOutActivity extends AppCompatActivity {
    private BaseWv wv;
    private  String cwrNo;
    private String host;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_check_in_or_out);


        Bundle bundle = this.getIntent().getExtras();
        //接收name值
        cwrNo = bundle.getString("cwrNo");
        host = getSp();

        if (host == null || host.length() < 1){
            App.getApp().showToast("请设置服务器地址");
            return;
        }
        wv = (BaseWv)findViewById(R.id.check_in_out_id);

    }

    public String getSp(){
        SharedPreferences sp = getSharedPreferences("sp_setting", 0);
        return sp.getString("server_host", "");
    }

    @Override
    protected void onStart(){
        super.onStart();
        wv.loadUrl("file:///android_asset/InAndOut.html?host=" + host + "&cwrNo=" + cwrNo + "");
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // TODO Auto-generated method stub
        switch(item.getItemId()){
            case R.id.action_settings:
                Intent i = new Intent(CheckInOrOutActivity.this, SettingActivity.class);
                this.startActivity(i);
                finish();
                break;

            default:
                break;
        }

        return super.onOptionsItemSelected(item);
    }
}
